import os
from dotenv import load_dotenv

load_dotenv()

HOSTNAME = '127.0.0.1'
PORT = '3306'
DATABASE = 'personal_blog'
USERNAME = 'root'
PASSWORD = '123456'
DB_URL = 'mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8'.format(USERNAME, PASSWORD, HOSTNAME, PORT, DATABASE)
JWT_SECRET_KEY='1f3d8a7c6b5e2f9a4d0c8e7b6a5d3f1'
JWT_ACCESS_TOKEN_EXPIRES=6000  # 访问令牌过期时间（秒，默认 1 小时）
JWT_REFRESH_TOKEN_EXPIRES=86400  # 刷新令牌过期时间（秒，默认 7 天）

"""
配置类
"""
class Config:
    SECRET_KEY = os.getenv('SECRET_KEY', 'default-secret-key')
    SQLALCHEMY_DATABASE_URI = DB_URL
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    JWT_SECRET_KEY = os.getenv('JWT_SECRET_KEY', '1f3d8a7c6b5e2f9a4d0c8e7b6a5d3f1')
    JWT_ACCESS_TOKEN_EXPIRES = int(os.getenv('JWT_ACCESS_TOKEN_EXPIRES', 6000))
    JWT_REFRESH_TOKEN_EXPIRES = int(os.getenv('JWT_REFRESH_TOKEN_EXPIRES', 86400))

class DevelopmentConfig(Config):
    DEBUG = True

class ProductionConfig(Config):
    DEBUG = False

config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig
}